<?php

class AcreditacionMultiplesRequisitosForm  extends sfForm
{
  public function configure()
  {

        unset(
                $this['created_at'], $this['updated_at'], $this['created_by'], $this['updated_by']
        );
    
    if (!$requisitos = $this->getOption('requisitos'))
    {
      throw new InvalidArgumentException('Debe indicar los requisitos a cargar.');
    } else if (!$aid = $this->getOption('aid')) {
      throw new InvalidArgumentException('Debe indicar el alumno.');
    }
    if(count($requisitos))
    {
      foreach($requisitos as $idx => $requisito) {
         $ac = $requisito->getNuevaAcreditacionPara($aid);
         $claseForm = 'Acreditacion'.$ac->getTipoRequisito().'Form';
         $this->embedForm(
           ($idx+1),
           new $claseForm($ac)
         );
      }
    }
  }
  
  public function quitarVacios() {
    foreach ($this->embeddedForms as $name => $form) {
  		if ($form->estaVacio()) unset($this[$name]);
    }
  }

}
